import axios from 'axios'

export default function axiosFunc(url, options) {
    var data = null;
    if (options.method === 'get') {
        console.log(url)
        return axios.get(url)
            .then(function (response) {
                data = response.data;
                console.log(data)
                data = data.replace("=", ":");
                data = eval('(' + data + ')');
                console.log('Return', data)
                return { data }
            })
            .catch(function (error) {
                console.log(error);
            });
    } else {
        return axios.post(url, JSON.stringify(options.data))
            .then(function (response) {
                console.log(response);
            })
            .catch(function (error) {
                console.log(error);
            });
    }
}